package com.example.logic.chapter8.demo01;

import java.util.Random;

public class DynamicArrayClient {
    public static void main(String[] args) {
        DynamicArray<Double> arr = new DynamicArray<>();
        Random random = new Random();

        int size = 1 + random.nextInt(100);
        for (int i = 0; i < size; i++) {
            arr.add(Math.random());
        }
        Double d = arr.get(random.nextInt(size));
        System.out.println(d);

        System.out.println("d = " + d);
        System.out.println("---------------------------");
        DynamicArray<Pair0<Integer, String>> arr0 = new DynamicArray<>();


        DynamicArray<Integer> ints = new DynamicArray<>();
        DynamicArray<? extends Number> numbers = ints;
        Integer a = 200;
        // numbers.add(a); // 错误的


        DynamicArray<Integer> ints0 = new DynamicArray<>();
        ints0.add(100);
        ints0.add(34);
        DynamicArray<Number> numbers0 = new DynamicArray<>();
        // 编译错误
        // ints0.copyTo(numbers0);
        ints0.copyTo0(numbers0);

        // 创建数组
        Pair0[] pair0s = new Pair0[]{
                new Pair0<>("1", "22"),
                new Pair0("22", "3")
        };
    }
}
